﻿using EntityModel;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;

namespace Super_Star.Controllers
{
    [Route("api/[controller]")]
    [ApiController]
    public class DepartmentController : ControllerBase
    {
        private readonly APIDBContext db;
        public DepartmentController(APIDBContext context)
        {
            db = context;
        }
        [HttpGet]
        public Result Get()
        {
            Result result = new Result();

            var resulrData = EM_Department.ToList<EM_Department>();
            result.Data = resulrData;
            result.Code = 200;
            result.Author = "123456@qq.com";
            return result;
        }
        [HttpPost]
        public Result AddDepartment([FromBody]EM_Department department)
        {
            Result result = new Result();
            db.EM_Department.Add(department);
            db.SaveChanges();

            return result;
        }
        
    }
}
